package com.gxa.jjty.admin.controller;

import com.github.pagehelper.PageInfo;
import com.gxa.jjty.admin.service.PhyNowStateService;
import com.gxa.jjty.admin.service.PhyUserService;
import com.gxa.jjty.core.common.JsonResult;
import com.gxa.jjty.core.pojo.PhyNowStateVO;
import com.gxa.jjty.core.pojo.PhyUser;
import com.gxa.jjty.core.util.MD5Util;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.sql.Timestamp;
import java.util.Map;

/**
 * @ClassName PhyUserController
 * @Author: ws
 * @date 2021/12/2 15:18
 */
@Log4j2
@RestController
@RequestMapping("/phyNowState")
@Api(tags = "陪护员当前状态列表的接口")

public class PhyNowStateController {

    @Autowired
    PhyNowStateService phyNowStateService;

    @PostMapping("/getALL")
    @ApiOperation("分页全查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页数"),
            @ApiImplicitParam(name = "size", value = "每页记录数")
    })
    public Map getAll(@RequestParam("page") Integer page, @RequestParam("size") Integer size) throws IllegalAccessException {

        PageInfo<PhyNowStateVO> pageInfo = phyNowStateService.selectByPageAnd(page, size);

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(pageInfo.getList());
        jsonResult.put("total",pageInfo.getTotal());

        return jsonResult.getDataMap();
    }


    @PostMapping("/getALLBy")
    @ApiOperation("分页全/带条件模糊查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页数",paramType = "query",dataType = "int"),
            @ApiImplicitParam(name = "size", value = "每页记录数",paramType = "query",dataType = "int"),
            @ApiImplicitParam(name = "name", value = "姓名",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "area", value = "区域",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "serverState", value = "服务状态",paramType = "query",dataType = "String"),
    })
    public Map getByTimeAnd(@RequestParam("page") Integer page, @RequestParam("size") Integer size,
                            @ApiIgnore PhyNowStateVO phyNowStateVO) throws IllegalAccessException {

        PageInfo<PhyNowStateVO> pageInfo = phyNowStateService.selectByPageAnd(page, size, phyNowStateVO);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(pageInfo.getList());
        jsonResult.put("total",pageInfo.getTotal());

        return jsonResult.getDataMap();
    }



}
